package io.characterStream.bufferedRorW.test;
/*
将出师表排序
 */
import java.io.*;
import java.util.TreeSet;

public class test1 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("HDay08\\C.txt"));
        //创建treeset集合排序
        TreeSet<String> ts = new TreeSet<>();
        String line;
        while ((line = br.readLine()) != null) {
            ts.add(line);
        }
        br.close();
        ts.forEach(s -> System.out.println(s));
        //写入文件
        BufferedWriter bw = new BufferedWriter(new FileWriter("HDay09\\C.txt"));
        for (String t : ts) {
            bw.write(t);
            bw.newLine();
        }
        bw.close();
    }
}
